home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / phcpc.bst < prev    next >
Lisp/Scheme  |  1992-07-19  |  61KB  |  1,886 lines

  1. % BibTeX styles for various physics journals (27-Feb-1990).
  2. % This file, physics.btx, is based on the file btxbst.doc.
  3.     % Please notify Charles Karney (Karney@Princeton.EDU)
  4.     % of any bugs, improvements, etc.
  5. % Run this file through cpp to get specific versions.  I have written
  6. % a version of cpp within Emacs.  To access it put
  7. %    (autoload 'cpp "tex$bibtex:cpp"        ; Use cpp for BibTeX styles
  8. %          "C preprocessor"
  9. %          t)
  10. % into your .emacs file.  Read in this file with
  11. %    emacs tex$bibtex:physics.btx
  12. % and run cpp with e.g.,
  13. %    M-x cpp <ret> aip <ret>
  14. % Save the resulting file to tex$latex:aip.bst.
  15. % To accomodate the variations we need (in addition to the definitions below)
  16. %    ATIT_SUPPRESS:    do not include the titles of journal articles
  17. %    NAME_INVERT:    put the initials last
  18. %    NAME_UPPER:    convert names to all caps.
  19. %    MONTH_SUPPRESS:    do not include months in journal articles
  20. %    PAREN_DATE:    dates go in parens in journal articles
  21. %    DATE_FIRST:    dates go before page numbers
  22. %    VOLUME_SPACE:    volume set off with space (not colon)
  23. %    NUM_SUPPRESS:    do not include numbers in journal articles
  24. %    BOLD_VOL:    volume numbers in bold face in journal articles
  25. %    BRACKET_NOTE:    notes in brackets
  26. %    PAGE_START_J:    include only starting page for journal articles
  27. %    PAGE_START_O:    include only starting page for other entries
  28. %    PAGE_ABBREV:    abbreviate page to p. and pages to pp.
  29. %    PHYSICS_JOUR:    include abbreviations for Physics journals
  30. %    COMMA_DELIMIT:    use comma (instead of period) to divide a citation
  31. %    NOTE_SUPPRESS:    suppress the note
  32. %    MAX_NAMES:    max number of authors before using et al (0 = infinity)
  33. %    MIN_NAMES:    number of authors to list with et al.
  34. %    EDIT_VAR:    use "edited by ..." instead of "..., editors"
  35. %    RMP_LABELS:    create RMP-style labels
  36. %    KEY_CITE:    use key as label
  37. %    NAMED_REFS:    use (Smith, 1988) style of citations
  38. %    CSC_NAMES:    names set in caps and small caps
  39. %    JOUR_DEEMPH:    don't emphasize journal name
  40. %    ETAL_EMPH:    emphasize et al.
  41. %    ALT_INCOLL    alternate ordering of fields in incollections
  42. % These are all boolean (0 or 1) except for MAX_NAMES and MIN_NAMES.
  43. % These need to satisfy 0 <= MIN_NAMES <= MAX_NAMES.
  44. % The rule here is that if all these are defined to be zero, we revert to
  45. % the standard styles.  For that reason we initialize them all to 0.
  46. % These are the original macros
  47.     % For Computer Physics Communications
  48. % same as AIP except for 0, 0
  49. % This is the start of btxbst.doc
  50. % BibTeX `plain' family
  51.     % version 0.99b for BibTeX versions 0.99a or later, LaTeX version 2.09.
  52.     % Copyright (C) 1985, all rights reserved.
  53.     % Copying of this file is authorized only if either
  54.     % (1) you make absolutely no changes to your copy, including name, or
  55.     % (2) if you do make changes, you name it something other than
  56.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  57.     % This restriction helps ensure that all standard styles are identical.
  58.     % The file btxbst.doc has the documentation for this style.
  59. % Please notify Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU) of any bugs in
  60. % these standard styles or in this documentation file.
  61. %
  62. % This is file btxbxt.doc; it helps document bibliography styles,
  63. % and is also a template file that you can use to make
  64. % several different style files, if you have access to a C preprocessor.
  65. % For example, the standard styles were made by doing something like
  66. %    cpp -P -DPLAIN btxbst.doc plain.txt
  67. %    cpp -P -DUNSRT btxbst.doc unsrt.txt
  68. %    cpp -P -DALPHA btxbst.doc alpha.txt
  69. %    cpp -P -DABBRV btxbst.doc abbrv.txt
  70. % and then renaming after removing unwanted comments and blank lines.
  71. % If you don't have access,
  72. % you can edit this file by hand to imitate the preprocessor,
  73. % with the following explanation of the C preprocessor constructs used here.
  74. %
  75. % The output of the preprocessor is the same as the input, except that certain
  76. % lines will be excluded (and some blank lines will be added).  The sequence
  77. %    #if VAR
  78. %        lines to be included when VAR is not zero
  79. %    #else
  80. %        lines to be included when VAR is zero
  81. %    #endif
  82. % (with the #-signs appearing in column 1) means that one set or the other of
  83. % the lines are to be included depending on the value of VAR.
  84. % The #else part is optional.  Comments can be added after #else and #endif.
  85. % Variables can be set by
  86. %    #define VAR value
  87. % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
  88. % to see if it has none.
  89. % Another #if form used in this file is #if !VAR, which includes the lines
  90. % after the #if only if VAR is zero.
  91. %
  92. % Convention: Use all uppercase identifiers for these preprocessor variables
  93. % so you can spot them easily
  94. %
  95. % The command line to the preprocessor should define one of PLAIN, UNSRT, ALPHA
  96. % or ABBRV (though PLAIN will be used by default if none is given),
  97. % and the following lines will set various boolean variables to control the
  98. % various lines that are chosen from the rest of the file.
  99. % Each boolean variable should be set true (1) or false (0) in each style.
  100. % Here are the current variables, and their meanings:
  101. %    0:    an alphabetic label is used (if false then a numeric
  102. %                label is used)
  103. %    0:        the entries should be sorted by label (if nonnumeric)
  104. %                and other info, like authors (if false, then
  105. %                entries remain in order of occurrence)
  106. %    0:    the authors, editors, etc., get the full names as
  107. %                given in the bibliography file (if false, the first
  108. %                names become initials)
  109. %    1:    titles of non-"books" (e.g., articles) should be
  110. %                converted to lower-case, except the first letter or
  111. %                first letter after a colon
  112. %                (if false then they appear as in the database)
  113. %    0:    months are spelled out in full (if false, then
  114. %                they're abbreviated)
  115. %    0:    macro journal names are spelled out in full
  116. %                (if false then they are abbreviated, currently
  117. %                as they appear in ACM publications)
  118. %#        define PLAIN 1
  119. %
  120. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  121. %    in "A Handbook for Scholars".  Book-like titles are italicized
  122. %    (emphasized) and non-book titles are converted to sentence
  123. %    capitilization (and not enclosed in quotes).
  124. %    This file outputs a \newblock between major blocks of an entry
  125. %    (the name \newblock is analogous to the names \newline and \newpage)
  126. %    so that the user can obtain an "open" format, which has a line break
  127. %    before each block and lines after the first are indented within blocks,
  128. %    by giving the optional \documentstyle argument `openbib';
  129. %    The default is the "closed" format---blocks runs together.
  130. %
  131. %   Citation alphabetic label format:
  132. %        [Knu73] for single author (or editor or key)
  133. %        [AHU83] (first letters of last names) for multiple authors
  134. %
  135. %   Citation label numberic format:
  136. %        [number]
  137. %
  138. %   Reference list ordering for sorted, alphabetic lables:
  139. %        alphabetical by citation label, then by author(s) or whatever
  140. %        passes for author in the absence of one, then by year,
  141. %        then title
  142. %
  143. %   Reference list ordering for sorted, numeric lables:
  144. %        alphabetical by author(s) or whatever passes
  145. %        for author in the absence of one, then by year, then title
  146. %
  147. %   Reference list ordering for unsorted:
  148. %        by the order cited in the text
  149. %
  150. %   History
  151. %   12/16/84    (HWT)    Original `plain' version, by Howard Trickey.
  152. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  153. %    2/16/85    (OP)    Changes based on LL's comments, Oren Patashnik.
  154. %    2/17/85    (HWT)    Template file and other standard styles made.
  155. %    3/28/85    (OP)    First release, version 0.98b for BibTeX 0.98f.
  156. %    5/ 9/85    (OP)    Version 0.98c for BibTeX 0.98i:
  157. %            fixed Theoretical Computer Science macro name;
  158. %            fixed the format.vol.num.pages function.
  159. %    1/24/88    (OP)    Version 0.99a for BibTeX 0.99a, main changes:
  160. %            assignment operator (:=) arguments reversed;
  161. %            the preamble$ function outputs the database PREAMBLE;
  162. %            entry.max$ and global.max$ (built-in) variables replace
  163. %            entry.string.max and global.string.max functions;
  164. %            alphabetizing by year then title, not just title;
  165. %            many unnecessary ties removed; \it ==> \em;
  166. %            the `alpha' style uses a superscripted `+' instead of a
  167. %            `*' for unnamed names in constructing the label;
  168. %            the `abbrv' style now uses "Mar." and "Sept.";
  169. %            the functions calc.label and presort now look at just
  170. %            the fields they're supposed to;
  171. %            BOOKLET, MASTERSTHESIS, TECHREPORT use nonbook titles;
  172. %            INBOOK and INCOLLECTION take an optional type (e.g.
  173. %            type = "Section"), overriding the default "chapter";
  174. %            BOOK, INBOOK, INCOLLECTION, and PROCEEDINGS now allow
  175. %            either volume or number, not just volume;
  176. %            INCOLLECTION now allows an edition and series field;
  177. %            PROCEEDINGS and INPROCEEDINGS now use the address field
  178. %            to tell where a conference was held;
  179. %            INPROCEEDINGS and PROCEEDINGS now allow either volume
  180. %            or number, and also a series field;
  181. %            MASTERSTHESIS and PHDTHESIS accept types other than
  182. %            "Master's thesis" and "PhD thesis";
  183. %            UNPUBLISHED now outputs, in one block, note then date;
  184. %            MANUAL now prints out the organization in
  185. %            the first block if the author field is empty;
  186. %            MISC can't be empty---it requires some optional field.
  187. %    3/23/88    (OP)    Version 0.99b for BibTeX 0.99c---changed the three
  188. %            erroneous occurrences of `cite ' to `cite$ '; this
  189. %            change didn't affect the four standard styles, so the
  190. %            0.99a versions of those styles are still current.
  191. %
  192. % The ENTRY declaration
  193. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  194. %   but no fullauthor or editors fields because BibTeX does name handling.
  195. %   The annote field is commented out here because this family doesn't
  196. %   include an annotated bibliography style.  And in addition to the fields
  197. %   listed here, BibTeX has a built-in crossref field, explained later.
  198. ENTRY
  199. % Fields:
  200.   { address
  201. %        Usually the address of a publisher or other type of organization.
  202. %        Put information in this field only if it helps the reader find the
  203. %        thing---for example you should omit the address of a major
  204. %        publisher entirely.  For a PROCEEDINGS or an INPROCEEDINGS,
  205. %        however, it's the address of the conference; for those two entry
  206. %        types, include the publisher's or organization's address, if
  207. %        necessary, in the publisher or organization field.
  208. %    annote
  209. %        Long annotation---for annotated bibliographies (begins sentence).
  210.     author
  211. %        Name(s) of author(s), in BibTeX name format.
  212.     booktitle
  213. %        Book title when the thing being referenced isn't the whole book.
  214. %        For book entries, the title field should be used instead.
  215.     chapter
  216. %        Chapter (or section or whatever) number.
  217.     edition
  218. %        Edition of a book---should be an ordinal (e.g., "Second").
  219.     editor
  220. %        Name(s) of editor(s), in BibTeX name format.
  221. %        If there is also an author field, then the editor field should be
  222. %        for the book or collection that the work appears in.
  223.     howpublished
  224. %         How something strange has been published (begins sentence).
  225.     institution
  226. %        Sponsoring institution of a technical report.
  227.     journal
  228. %        Journal name (macros are provided for many).
  229.     key
  230. %        Alphabetizing, labeling, and cross-referencing key
  231. %        (needed when an entry has no author or editor).
  232.     month
  233. %        Month (macros are provided).
  234.     note
  235. %        To help the reader find a reference (begins sentence).
  236.     number
  237. %        Number of a journal or technical report, or of a work in a series.
  238.     organization
  239. %        Organization sponsoring a conference (or publishing a manual); if
  240. %        the editor (or author) is empty, and if the organization produces
  241. %        an awkward label or cross reference, you should put appropriately
  242. %        condensed organization information in the key field as well.
  243.     pages
  244. %        Page number or numbers (use `--' to separate a range, use `+'
  245. %        to indicate pages following that don't form a simple range).
  246.     publisher
  247. %        Publisher name.
  248.     school
  249. %        School name (for theses).
  250.     series
  251. %        The name of a series or set of books.
  252. %        An individual book will will also have it's own title.
  253.     title
  254. %        The title of the thing you're referred to.
  255.     type
  256. %        Type of a Techreport (e.g., "Research Note") to be used instead of
  257. %        the default "Technical Report"; or, similarly, the type of a
  258. %        thesis; or of a part of a book.
  259.     volume
  260. %        The volume number of a journal or multivolume work.
  261.     year
  262. %        The year should contain only numerals (technically, it should end
  263. %        with four numerals, after purification; doesn't a begin sentence).
  264.   }
  265. % There are no integer entry variables
  266.   {}
  267. % These string entry variables are used to form the citation label.
  268. % In a storage pinch, sort.label can be easily computed on the fly.
  269.   { label }
  270. % Each entry function starts by calling output.bibitem, to write the
  271. % \bibitem and its arguments to the .BBL file.  Then the various fields
  272. % are formatted and printed by output or output.check.  Those functions
  273. % handle the writing of separators (commas, periods, \newblock's),
  274. % taking care not to do so when they are passed a null string.
  275. % Finally, fin.entry is called to add the final period and finish the
  276. % entry.
  277. %
  278. % A bibliographic reference is formatted into a number of `blocks':
  279. % in the open format, a block begins on a new line and subsequent
  280. % lines of the block are indented.  A block may contain more than
  281. % one sentence (well, not a grammatical sentence, but something to
  282. % be ended with a sentence ending period).  The entry functions should
  283. % call new.block whenever a block other than the first is about to be
  284. % started.  They should call new.sentence whenever a new sentence is
  285. % to be started.  The output functions will ensure that if two
  286. % new.sentence's occur without any non-null string being output between
  287. % them then there won't be two periods output.  Similarly for two
  288. % successive new.block's.
  289. %
  290. % The output routines don't write their argument immediately.
  291. % Instead, by convention, that argument is saved on the stack to be
  292. % output next time (when we'll know what separator needs to come
  293. % after it).  Meanwhile, the output routine has to pop the pending
  294. % output off the stack, append any needed separator, and write it.
  295. %
  296. % To tell which separator is needed, we maintain an output.state.
  297. % It will be one of these values:
  298. %    before.all        just after the \bibitem
  299. %    mid.sentence        in the middle of a sentence: comma needed
  300. %                    if more sentence is output
  301. %    after.sentence        just after a sentence: period needed
  302. %    after.block        just after a block (and sentence):
  303. %                    period and \newblock needed.
  304. % Note: These styles don't use after.sentence
  305. %
  306. % VAR: output.state : INTEGER        -- state variable for output
  307. %
  308. % The output.nonnull function saves its argument (assumed to be nonnull)
  309. % on the stack, and writes the old saved value followed by any needed
  310. % separator.  The ordering of the tests is decreasing frequency of
  311. % occurrence.
  312. %
  313. % output.nonnull(s) ==
  314. %  BEGIN
  315. %    s := argument on stack
  316. %    if output.state = mid.sentence then
  317. %        write$(pop() * ", ")
  318. %          -- "pop" isn't a function: just use stack top
  319. %    else
  320. %        if output.state = after.block then
  321. %        write$(add.period$(pop()))
  322. %        newline$
  323. %        write$("\newblock ")
  324. %        else
  325. %        if output.state = before.all then
  326. %            write$(pop())
  327. %        else        -- output.state should be after.sentence
  328. %            write$(add.period$(pop()) * " ")
  329. %        fi
  330. %        fi
  331. %        output.state := mid.sentence
  332. %    fi
  333. %    push s on stack
  334. %  END
  335. %
  336. % The output function calls output.nonnull if its argument is non-empty;
  337. % its argument may be a missing field (thus, not necessarily a string)
  338. %
  339. % output(s) ==
  340. %  BEGIN
  341. %    if not empty$(s) then output.nonnull(s)
  342. %    fi
  343. %  END
  344. %
  345. % The output.check function is the same as the output function except that, if
  346. % necessary, output.check warns the user that the t field shouldn't be empty
  347. % (this is because it probably won't be a good reference without the field;
  348. % the entry functions try to make the formatting look reasonable even when
  349. % such fields are empty).
  350. %
  351. % output.check(s,t) ==
  352. %  BEGIN
  353. %    if empty$(s) then
  354. %        warning$("empty " * t * " in " * cite$)
  355. %    else output.nonnull(s)
  356. %    fi
  357. %  END
  358. %
  359. % The output.bibitem function writes the \bibitem for the current entry
  360. % (the label should already have been set up), and sets up the separator
  361. % state for the output functions.  And, it leaves a string on the stack
  362. % as per the output convention.
  363. %
  364. % output.bibitem ==
  365. %  BEGIN
  366. %    newline$
  367. %    write$("\bibitem[")    % for alphabetic labels,
  368. %    write$(label)        % these three lines
  369. %    write$("]{")        % are used
  370. %    write$("\bibitem{")        % this line for numeric labels
  371. %    write$(cite$)
  372. %    write$("}")
  373. %    push "" on stack
  374. %    output.state := before.all
  375. %  END
  376. %
  377. % The fin.entry function finishes off an entry by adding a period to the
  378. % string remaining on the stack.  If the state is still before.all
  379. % then nothing was produced for this entry, so the result will look bad,
  380. % but the user deserves it. (We don't omit the whole entry because the
  381. % entry was cited, and a bibitem is needed to define the citation label.)
  382. %
  383. % fin.entry ==
  384. %  BEGIN
  385. %    write$(add.period$(pop()))
  386. %    newline$
  387. %  END
  388. %
  389. % The new.block function prepares for a new block to be output, and
  390. % new.sentence prepares for a new sentence.
  391. %
  392. % new.block ==
  393. %  BEGIN
  394. %    if output.state <> before.all then
  395. %        output.state := after.block
  396. %    fi
  397. %  END
  398. %
  399. % new.sentence ==
  400. %  BEGIN
  401. %    if output.state <> after.block then
  402. %        if output.state <> before.all then
  403. %        output.state :=  after.sentence
  404. %        fi
  405. %    fi
  406. %  END
  407. %
  408. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  409. FUNCTION {init.state.consts}
  410. { #0 'before.all :=
  411.   #1 'mid.sentence :=
  412.   #2 'after.sentence :=
  413.   #3 'after.block :=
  414. }
  415. % the variables s and t are temporary string holders
  416. STRINGS { s t }
  417. FUNCTION {output.nonnull}
  418. { 's :=
  419.   output.state mid.sentence =
  420.     { ", " * write$ }
  421.     { output.state after.block =
  422.     { "," * write$
  423.       newline$
  424.       "\newblock " write$
  425.     }
  426.     { output.state before.all =
  427.         'write$
  428.         { add.period$ " " * write$ }
  429.       if$
  430.     }
  431.       if$
  432.       mid.sentence 'output.state :=
  433.     }
  434.   if$
  435.   s
  436. }
  437. FUNCTION {output}
  438. { duplicate$ empty$
  439.     'pop$
  440.     'output.nonnull
  441.   if$
  442. }
  443. FUNCTION {output.check}
  444. { 't :=
  445.   duplicate$ empty$
  446.     { pop$ "empty " t * " in " * cite$ * warning$ }
  447.     'output.nonnull
  448.   if$
  449. }
  450. FUNCTION {output.bibitem}
  451. { newline$
  452.   "\bibitem{" write$
  453.   cite$ write$
  454.   "}" write$
  455.   newline$
  456.   ""
  457.   before.all 'output.state :=
  458. }
  459. % This function finishes all entries.
  460. FUNCTION {fin.entry}
  461. { add.period$
  462.   write$
  463.   newline$
  464. }
  465. FUNCTION {new.block}
  466. { output.state before.all =
  467.     'skip$
  468.     { after.block 'output.state := }
  469.   if$
  470. }
  471. FUNCTION {new.sentence}
  472. { skip$
  473. }
  474. % These three functions pop one or two (integer) arguments from the stack
  475. % and push a single one, either 0 or 1.
  476. % The 'skip$ in the `and' and `or' functions are used because
  477. % the corresponding if$ would be idempotent
  478. FUNCTION {not}
  479. {   { #0 }
  480.     { #1 }
  481.   if$
  482. }
  483. FUNCTION {and}
  484. {   'skip$
  485.     { pop$ #0 }
  486.   if$
  487. }
  488. FUNCTION {or}
  489. {   { pop$ #1 }
  490.     'skip$
  491.   if$
  492. }
  493. % Sometimes we begin a new block only if the block will be big enough.  The
  494. % new.block.checka function issues a new.block if its argument is nonempty;
  495. % new.block.checkb does the same if either of its TWO arguments is nonempty.
  496. FUNCTION {new.block.checka}
  497. { empty$
  498.     'skip$
  499.     'new.block
  500.   if$
  501. }
  502. FUNCTION {new.block.checkb}
  503. { empty$
  504.   swap$ empty$
  505.   and
  506.     'skip$
  507.     'new.block
  508.   if$
  509. }
  510. % The new.sentence.check functions are analogous.
  511. FUNCTION {new.sentence.checka}
  512. { empty$
  513.     'skip$
  514.     'new.sentence
  515.   if$
  516. }
  517. FUNCTION {new.sentence.checkb}
  518. { empty$
  519.   swap$ empty$
  520.   and
  521.     'skip$
  522.     'new.sentence
  523.   if$
  524. }
  525. % Here are some functions for formatting chunks of an entry.
  526. % By convention they either produce a string that can be followed by
  527. % a comma or period (using add.period$, so it is OK to end in a period),
  528. % or they produce the null string.
  529. %
  530. % A useful utility is the field.or.null function, which checks if the
  531. % argument is the result of pushing a `missing' field (one for which no
  532. % assignment was made when the current entry was read in from the database)
  533. % or the result of pushing a string having no non-white-space characters.
  534. % It returns the null string if so, otherwise it returns the field string.
  535. % Its main (but not only) purpose is to guarantee that what's left on the
  536. % stack is a string rather than a missing field.
  537. %
  538. % field.or.null(s) ==
  539. %  BEGIN
  540. %    if empty$(s) then return ""
  541. %    else return s
  542. %  END
  543. %
  544. % Another helper function is emphasize, which returns the argument emphazised,
  545. % if that is non-empty, otherwise it returns the null string.  Italic
  546. % corrections aren't used, so this function should be used when punctation
  547. % will follow the result.
  548. %
  549. % emphasize(s) ==
  550. %  BEGIN
  551. %    if empty$(s) then return ""
  552. %    else return "{\em " * s * "}"
  553. %
  554. % The format.names function formats the argument (which should be in
  555. % BibTeX name format) into "First Von Last, Junior", separated by commas
  556. % and with an "and" before the last (but ending with "et~al." if the last
  557. % of multiple authors is "others").  This function's argument should always
  558. % contain at least one name.
  559. %
  560. % VAR: nameptr, namesleft, numnames: INTEGER
  561. % pseudoVAR: nameresult: STRING        (it's what's accumulated on the stack)
  562. %
  563. % format.names(s) ==
  564. %  BEGIN
  565. %    nameptr := 1
  566. %    numnames := num.names$(s)
  567. %    namesleft := numnames
  568. %    while namesleft > 0
  569. %      do
  570. %                % for full names:
  571. %        t := format.name$(s, nameptr, "{ff~}{vv~}{ll}{, jj}")
  572. %                % for abbreviated first names:
  573. %        t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
  574. %        if nameptr > 1 then
  575. %        if namesleft > 1 then nameresult := nameresult * ", " * t
  576. %        else if numnames > 2
  577. %               then nameresult := nameresult * ","
  578. %             fi
  579. %             if t = "others"
  580. %               then nameresult := nameresult * " et~al."
  581. %               else nameresult := nameresult * " and " * t
  582. %             fi
  583. %        fi
  584. %        else nameresult := t
  585. %        fi
  586. %        nameptr := nameptr + 1
  587. %        namesleft := namesleft - 1
  588. %      od
  589. %    return nameresult
  590. %  END
  591. %
  592. % The format.authors function returns the result of format.names(author)
  593. % if the author is present, or else it returns the null string
  594. %
  595. % format.authors ==
  596. %  BEGIN
  597. %    if empty$(author) then return ""
  598. %    else return format.names(author)
  599. %    fi
  600. %  END
  601. %
  602. % Format.editors is like format.authors, but it uses the editor field,
  603. % and appends ", editor" or ", editors"
  604. %
  605. % format.editors ==
  606. %  BEGIN
  607. %    if empty$(editor) then return ""
  608. %    else
  609. %        if num.names$(editor) > 1 then
  610. %        return format.names(editor) * ", editors"
  611. %        else
  612. %        return format.names(editor) * ", editor"
  613. %        fi
  614. %    fi
  615. %  END
  616. %
  617. % Other formatting functions are similar, so no "comment version" will be
  618. % given for them.
  619. %
  620. % The `pop$' in this function gets rid of the duplicate `empty' value and
  621. % the `skip$' returns the duplicate field value
  622. FUNCTION {field.or.null}
  623. { duplicate$ empty$
  624.     { pop$ "" }
  625.     'skip$
  626.   if$
  627. }
  628. FUNCTION {emphasize}
  629. { duplicate$ empty$
  630.     { pop$ "" }
  631.     { "{\em " swap$ * "}" * }
  632.   if$
  633. }
  634. FUNCTION {embolden}
  635. { duplicate$ empty$
  636.     { pop$ "" }
  637.     { "{\bf " swap$ * "}" * }
  638.   if$
  639. }
  640. FUNCTION {paren}
  641. { duplicate$ empty$
  642.     { pop$ "" }
  643.     { "(" swap$ * ")" * }
  644.   if$
  645. }
  646. INTEGERS { nameptr namesleft numnames }
  647. INTEGERS { etal }
  648. FUNCTION {format.names}
  649. { 's :=
  650.   #1 'nameptr :=
  651.   s num.names$ 'numnames :=
  652.   numnames #5 >
  653.   s numnames "{ll}" format.name$ "others" = numnames #1 > and
  654.   or 'etal :=
  655.   etal
  656.     { #1 #1 + 'namesleft := }
  657.     { numnames 'namesleft := }
  658.   if$
  659.     { namesleft #0 > }
  660.     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=   % last name first
  661.       nameptr #1 >
  662.     { namesleft #1 >
  663.         { ", " * t * }
  664.         { nameptr #2 >
  665.         { "," * }
  666.         'skip$
  667.           if$
  668.           t "others" =
  669.           etal or
  670.         { " et~al." * }
  671.         { " and " * t * }
  672.           if$
  673.         }
  674.       if$
  675.     }
  676.     't
  677.       if$
  678.       nameptr #1 + 'nameptr :=
  679.       namesleft #1 - 'namesleft :=
  680.     }
  681.   while$
  682. }
  683. FUNCTION {format.authors}
  684. { author empty$
  685.     { "" }
  686.     { author format.names }
  687.   if$
  688. }
  689. FUNCTION {format.editors}
  690. { editor empty$
  691.     { "" }
  692.     { editor format.names
  693.       editor num.names$ #1 >
  694.     { ", editors" * }
  695.     { ", editor" * }
  696.       if$
  697.     }
  698.   if$
  699. }
  700. FUNCTION {format.edited}
  701. { editor empty$
  702.     { "" }
  703.     { "edited by " editor format.names * }
  704.   if$
  705. }
  706. % The format.title function is used for non-book-like titles.
  707. % For most styles we convert to lowercase (except for the very first letter,
  708. % and except for the first one after a colon (followed by whitespace)),
  709. % and hope the user has brace-surrounded words that need to stay capitilized;
  710. % for some styles, however, we leave it as it is in the database.
  711. FUNCTION {format.title}
  712. { title empty$
  713.     { "" }
  714.     { title "t" change.case$ }
  715.   if$
  716. }
  717. % By default, BibTeX sets the global integer variable global.max$ to the BibTeX
  718. % constant glob_str_size, the maximum length of a global string variable.
  719. % Analogously, BibTeX sets the global integer variable entry.max$ to
  720. % ent_str_size, the maximum length of an entry string variable.
  721. % The style designer may change these if necessary (but this is unlikely)
  722. % The n.dashify function makes each single `-' in a string a double `--'
  723. % if it's not already
  724. %
  725. % pseudoVAR: pageresult: STRING        (it's what's accumulated on the stack)
  726. %
  727. % n.dashify(s) ==
  728. %  BEGIN
  729. %    t := s
  730. %    pageresult := ""
  731. %    while (not empty$(t))
  732. %      do
  733. %        if (first character of t = "-")
  734. %          then
  735. %        if (next character isn't)
  736. %          then
  737. %            pageresult := pageresult * "--"
  738. %            t := t with the "-" removed
  739. %          else
  740. %            while (first character of t = "-")
  741. %              do
  742. %            pageresult := pageresult * "-"
  743. %            t := t with the "-" removed
  744. %              od
  745. %        fi
  746. %          else
  747. %        pageresult := pageresult * the first character
  748. %        t := t with the first character removed
  749. %        fi
  750. %      od
  751. %    return pageresult
  752. %  END
  753. FUNCTION {n.dashify}
  754. { 't :=
  755.   ""
  756.     { t empty$ not }
  757.     { t #1 #1 substring$ "-" =
  758.     { t #1 #2 substring$ "--" = not
  759.         { "--" *
  760.           t #2 global.max$ substring$ 't :=
  761.         }
  762.         {   { t #1 #1 substring$ "-" = }
  763.         { "-" *
  764.           t #2 global.max$ substring$ 't :=
  765.         }
  766.           while$
  767.         }
  768.       if$
  769.     }
  770.     { t #1 #1 substring$ *
  771.       t #2 global.max$ substring$ 't :=
  772.     }
  773.       if$
  774.     }
  775.   while$
  776. }
  777. FUNCTION {first.page}
  778. { 't :=
  779.   ""
  780.     {  t empty$ not t #1 #1 substring$ "-" = not and }
  781.     { t #1 #1 substring$ *
  782.       t #2 global.max$ substring$ 't :=
  783.     }
  784.   while$
  785. }
  786. % The format.date function is for the month and year, but we give a warning if
  787. % there's an empty year but the month is there, and we return the empty string
  788. % if they're both empty.
  789. FUNCTION {format.date}
  790. { year empty$
  791.     { "" }
  792.     'year
  793.   if$
  794. }
  795. % The format.btitle is for formatting the title field when it is a book-like
  796. % entry---the style used here keeps it in uppers-and-lowers and emphasizes it.
  797. FUNCTION {format.btitle}
  798. { title emphasize
  799. }
  800. % For several functions we'll need to connect two strings with a
  801. % tie (~) if the second one isn't very long (fewer than 3 characters).
  802. % The tie.or.space.connect function does that.  It concatenates the two
  803. % strings on top of the stack, along with either a tie or space between
  804. % them, and puts this concatenation back onto the stack:
  805. %
  806. % tie.or.space.connect(str1,str2) ==
  807. %    BEGIN
  808. %    if text.length$(str2) < 3
  809. %      then return the concatenation of str1, "~", and str2
  810. %      else return the concatenation of str1, " ", and str2
  811. %    END
  812. FUNCTION {tie.or.space.connect}
  813. { duplicate$ text.length$ #3 <
  814.     { "~" }
  815.     { " " }
  816.   if$
  817.   swap$ * *
  818. }
  819. % The either.or.check function complains if both fields or an either-or pair
  820. % are nonempty.
  821. %
  822. % either.or.check(t,s) ==
  823. %  BEGIN
  824. %    if empty$(s) then
  825. %        warning$(can't use both " * t * " fields in " * cite$)
  826. %    fi
  827. %  END
  828. FUNCTION {either.or.check}
  829. { empty$
  830.     'pop$
  831.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  832.   if$
  833. }
  834. % The format.bvolume function is for formatting the volume and perhaps
  835. % series name of a multivolume work.  If both a volume and a series field
  836. % are there, we assume the series field is the title of the whole multivolume
  837. % work (the title field should be the title of the thing being referred to),
  838. % and we add an "of <series>".  This function is called in mid-sentence.
  839. FUNCTION {format.bvolume}
  840. { volume empty$
  841.     { "" }
  842.     { "volume" volume tie.or.space.connect
  843.       series empty$
  844.     'skip$
  845.     { " of " * series emphasize * }
  846.       if$
  847.       "volume and number" number either.or.check
  848.     }
  849.   if$
  850. }
  851. % The format.number.series function is for formatting the series name
  852. % and perhaps number of a work in a series.  This function is similar to
  853. % format.bvolume, although for this one the series must exist (and the
  854. % volume must not exist).  If the number field is empty we output either
  855. % the series field unchanged if it exists or else the null string.
  856. % If both the number and series fields are there we assume the series field
  857. % gives the name of the whole series (the title field should be the title
  858. % of the work being one referred to), and we add an "in <series>".
  859. % We capitilize Number when this function is used at the beginning of a block.
  860. FUNCTION {format.number.series}
  861. { volume empty$
  862.     { number empty$
  863.     { series field.or.null }
  864.     { output.state mid.sentence =
  865.         { "number" }
  866.         { "Number" }
  867.       if$
  868.       number tie.or.space.connect
  869.       series empty$
  870.         { "there's a number but no series in " cite$ * warning$ }
  871.         { " in " * series * }
  872.       if$
  873.     }
  874.       if$
  875.     }
  876.     { "" }
  877.   if$
  878. }
  879. % The format.edition function appends " edition" to the edition, if present.
  880. % We lowercase the edition (it should be something like "Third"), because
  881. % this doesn't start a sentence.
  882. FUNCTION {format.edition}
  883. { edition empty$
  884.     { "" }
  885.     { output.state mid.sentence =
  886.     { edition "l" change.case$ " edition" * }
  887.     { edition "t" change.case$ " edition" * }
  888.       if$
  889.     }
  890.   if$
  891. }
  892. % The format.pages function is used for formatting a page range in a book
  893. % (and in rare circumstances, an article).
  894. %
  895. % The multi.page.check function examines the page field for a "-" or "," or "+"
  896. % so that format.pages can use "page" instead of "pages" if none exists.
  897. % Note: global.max$ here means "take the rest of the string"
  898. %
  899. % VAR: multiresult: INTEGER    (actually, a boolean)
  900. %
  901. % multi.page.check(s) ==
  902. %  BEGIN
  903. %    t := s
  904. %    multiresult := false
  905. %    while ((not multiresult) and (not empty$(t)))
  906. %      do
  907. %        if (first character of t = "-" or "," or "+")
  908. %          then multiresult := true
  909. %          else t := t with the first character removed
  910. %        fi
  911. %      od
  912. %    return multiresult
  913. %  END
  914. INTEGERS { multiresult }
  915. FUNCTION {multi.page.check}
  916. { 't :=
  917.   #0 'multiresult :=
  918.     { multiresult not
  919.       t empty$ not
  920.       and
  921.     }
  922.     { t #1 #1 substring$
  923.       duplicate$ "-" =
  924.       swap$ duplicate$ "," =
  925.       swap$ "+" =
  926.       or or
  927.     { #1 'multiresult := }
  928.     { t #2 global.max$ substring$ 't := }
  929.       if$
  930.     }
  931.   while$
  932.   multiresult
  933. }
  934. % This function doesn't begin a sentence so "pages" isn't capitalized.
  935. % Other functions that use this should keep that in mind.
  936. FUNCTION {format.pages}
  937. { pages empty$
  938.     { "" }
  939.     { pages multi.page.check
  940.     { "pages" pages n.dashify tie.or.space.connect }
  941.     { "page" pages tie.or.space.connect }
  942.       if$
  943.     }
  944.   if$
  945. }
  946. FUNCTION {format.pages.a}
  947. { pages empty$
  948.     { "" }
  949.     { "page" pages first.page tie.or.space.connect }
  950.   if$
  951. }
  952. % The format.vol.num.pages function is for the volume, number, and page range
  953. % of a journal article.  We use the format:  vol(number):pages, with some
  954. % variations for empty fields.  This doesn't begin a sentence.
  955. FUNCTION {format.vol.num.pages}
  956. { volume field.or.null embolden
  957.   " " swap$ * *
  958.   format.date empty$
  959.     'skip$
  960.     { duplicate$ empty$
  961.     { pop$ format.date paren }
  962.         { " " * format.date paren * }
  963.       if$
  964.     }
  965.   if$
  966.   pages empty$
  967.     'skip$
  968.     { duplicate$ empty$
  969.     { pop$ format.pages.a }
  970.     { " " * pages first.page *}
  971.       if$
  972.     }
  973.   if$
  974. }
  975. % The format.chapter.pages, if the chapter is present, puts whatever is in the
  976. % type field (or else "chapter" if type is empty) in front of a chapter number.
  977. % It then appends the pages, if present.  This doesn't begin a sentence.
  978. FUNCTION {format.chapter.pages}
  979. { chapter empty$
  980.     'format.pages
  981.     { type empty$
  982.     { "chapter" }
  983.     { type "l" change.case$ }
  984.       if$
  985.       chapter tie.or.space.connect
  986.       pages empty$
  987.     'skip$
  988.     { ", " * format.pages * }
  989.       if$
  990.     }
  991.   if$
  992. }
  993. % The format.in.ed.booktitle function is used for starting out a sentence
  994. % that begins "In <booktitle>", putting an editor before the title if one
  995. % exists.
  996. FUNCTION {format.in.ed.booktitle}
  997. { booktitle empty$
  998.     { "" }
  999.     { editor empty$
  1000.     { "in " booktitle emphasize * }
  1001.     { "in " booktitle emphasize * ", " * format.edited * }
  1002.       if$
  1003.     }
  1004.   if$
  1005. }
  1006. % The function empty.misc.check complains if all six fields are empty, and
  1007. % if there's been no sorting or alphabetic-label complaint.
  1008. FUNCTION {empty.misc.check}
  1009. { author empty$ title empty$ howpublished empty$
  1010.   month empty$ year empty$ note empty$
  1011.   and and and and and
  1012.     { "all relevant fields are empty in " cite$ * warning$ }
  1013.     'skip$
  1014.   if$
  1015. }
  1016. % The function format.thesis.type returns either the (case-changed) type field,
  1017. % if it is defined, or else the default string already on the stack
  1018. % (like "Master's thesis" or "PhD thesis").
  1019. FUNCTION {format.thesis.type}
  1020. { type empty$
  1021.     'skip$
  1022.     { pop$
  1023.       type "t" change.case$
  1024.     }
  1025.   if$
  1026. }
  1027. % The function format.tr.number makes a string starting with "Technical Report"
  1028. % (or type, if that field is defined), followed by the number if there is one;
  1029. % it returns the starting part (with a case change) even if there is no number.
  1030. % This is used at the beginning of a sentence.
  1031. FUNCTION {format.tr.number}
  1032. { type empty$
  1033.     { "Technical Report" }
  1034.     'type
  1035.   if$
  1036.   number empty$
  1037.     { "t" change.case$ }
  1038.     { number tie.or.space.connect }
  1039.   if$
  1040. }
  1041. % Now come the cross-referencing functions (these are invoked because
  1042. % one entry in the database file(s) cross-references another, by giving
  1043. % the other entry's database key in a `crossref' field).  This feature
  1044. % allows one or more titled things that are part of a larger titled
  1045. % thing to cross-reference the larger thing.  These styles allow for
  1046. % five posibilities: (1) an ARTICLE may cross-reference an ARTICLE;
  1047. % (2) a BOOK, (3) INBOOK, or (4) INCOLLECTION may cross-reference a BOOK;
  1048. % or (5) an INPROCEEDINGS may cross-reference a PROCEEDINGS.
  1049. % Each of these is explained in more detail later.
  1050. %
  1051. % An ARTICLE entry type may cross reference another ARTICLE (this is
  1052. % intended for when an entire journal is devoted to a single topic---
  1053. % but since there is no JOURNAL entry type, the journal, too, should be
  1054. % classified as an ARTICLE but without the author and title fields).
  1055. % This will result in two warning messages for the journal's entry
  1056. % if it's included in the reference list, but such is life.
  1057. %
  1058. % format.article.crossref ==
  1059. %  BEGIN
  1060. %    if empty$(key) then
  1061. %        if empty$(journal) then
  1062. %        warning$("need key or journal for " * cite$ *
  1063. %                        " to crossref " * crossref)
  1064. %        return(" \cite{" * crossref * "}")
  1065. %        else
  1066. %        return("In " * emphazise.correct (journal) *
  1067. %                        " \cite{" * crossref * "}")
  1068. %        fi
  1069. %    else
  1070. %        return("In " * key * " \cite{" * crossref * "}")
  1071. %    fi
  1072. %  END
  1073. %
  1074. % The other cross-referencing functions are similar, so no "comment version"
  1075. % will be given for them.
  1076. FUNCTION {format.article.crossref}
  1077. { key empty$
  1078.     { journal empty$
  1079.     { "need key or journal for " cite$ * " to crossref " * crossref *
  1080.       warning$
  1081.       ""
  1082.     }
  1083.     { "In " journal * }
  1084.       if$
  1085.     }
  1086.     { "In " key * }
  1087.   if$
  1088.   " \cite{" * crossref * "}" *
  1089. }
  1090. % We use just the last names of editors for a cross reference: either
  1091. % "editor", or "editor1 and editor2", or "editor1 et~al." depending on
  1092. % whether there are one, or two, or more than two editors.
  1093. FUNCTION {format.crossref.editor}
  1094. { editor #1 "{vv~}{ll}" format.name$
  1095.   editor num.names$ duplicate$
  1096.   #2 >
  1097.     { pop$ " et~al." * }
  1098.     { #2 <
  1099.     'skip$
  1100.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1101.         { " et~al." * }
  1102.         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  1103.       if$
  1104.     }
  1105.       if$
  1106.     }
  1107.   if$
  1108. }
  1109. % A BOOK (or INBOOK) entry type (assumed to be for a single volume in a
  1110. % multivolume work) may cross reference another BOOK (the entire multivolume).
  1111. % Usually there will be an editor, in which case we use that to construct the
  1112. % cross reference; otherwise we use a nonempty key field or else the series
  1113. % field (since the series gives the title of the multivolume work).
  1114. FUNCTION {format.book.crossref}
  1115. { volume empty$
  1116.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  1117.       "In "
  1118.     }
  1119.     { "Volume" volume tie.or.space.connect
  1120.       " of " *
  1121.     }
  1122.   if$
  1123.   editor empty$
  1124.   editor field.or.null author field.or.null =
  1125.   or
  1126.     { key empty$
  1127.     { series empty$
  1128.         { "need editor, key, or series for " cite$ * " to crossref " *
  1129.           crossref * warning$
  1130.           "" *
  1131.         }
  1132.         { "{\em " * series * "\/}" * }
  1133.       if$
  1134.     }
  1135.     { key * }
  1136.       if$
  1137.     }
  1138.     { format.crossref.editor * }
  1139.   if$
  1140.   " \cite{" * crossref * "}" *
  1141. }
  1142. % An INCOLLECTION entry type may cross reference a BOOK (assumed to be the
  1143. % collection), or an INPROCEEDINGS may cross reference a PROCEEDINGS.
  1144. % Often there will be an editor, in which case we use that to construct
  1145. % the cross reference; otherwise we use a nonempty key field or else
  1146. % the booktitle field (which gives the cross-referenced work's title).
  1147. FUNCTION {format.incoll.inproc.crossref}
  1148. { editor empty$
  1149.   editor field.or.null author field.or.null =
  1150.   or
  1151.     { key empty$
  1152.     { booktitle empty$
  1153.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  1154.           crossref * warning$
  1155.           ""
  1156.         }
  1157.         { "In {\em " booktitle * "\/}" * }
  1158.       if$
  1159.     }
  1160.     { "In " key * }
  1161.       if$
  1162.     }
  1163.     { "In " format.crossref.editor * }
  1164.   if$
  1165.   " \cite{" * crossref * "}" *
  1166. }
  1167. % Now we define the type functions for all entry types that may appear
  1168. % in the .BIB file---e.g., functions like `article' and `book'.  These
  1169. % are the routines that actually generate the .BBL-file output for
  1170. % the entry.  These must all precede the READ command.  In addition, the
  1171. % style designer should have a function `default.type' for unknown types.
  1172. % Note: The fields (within each list) are listed in order of appearance,
  1173. % except as described for an `inbook' or a `proceedings'.
  1174. %
  1175. % The article function is for an article in a journal.  An article may
  1176. % CROSSREF another article.
  1177. %    Required fields: author, title, journal, year
  1178. %    Optional fields: volume, number, pages, month, note
  1179. %
  1180. % article ==
  1181. %  BEGIN
  1182. %    output.bibitem
  1183. %    output.check(format.authors,"author")
  1184. %    new.block
  1185. %    output.check(format.title,"title")
  1186. %    new.block
  1187. %    if missing$(crossref) then
  1188. %        output.check(emphasize(journal),"journal")
  1189. %        output(format.vol.num.pages)
  1190. %        output.check(format.date,"year")
  1191. %       else
  1192. %        output.nonnull(format.article.crossref)
  1193. %        output(format.pages)
  1194. %    fi
  1195. %    new.block
  1196. %    output(note)
  1197. %    fin.entry
  1198. %  END
  1199. %
  1200. % The book function is for a whole book.  A book may CROSSREF another book.
  1201. %    Required fields: author or editor, title, publisher, year
  1202. %    Optional fields: volume or number, series, address, edition, month,
  1203. %            note
  1204. %
  1205. % book ==
  1206. %  BEGIN
  1207. %    if empty$(author) then output.check(format.editors,"author and editor")
  1208. %    else    output.check(format.authors,"author")
  1209. %        if missing$(crossref) then
  1210. %            either.or.check("author and editor",editor)
  1211. %        fi
  1212. %    fi
  1213. %    new.block
  1214. %    output.check(format.btitle,"title")
  1215. %    if missing$(crossref) then
  1216. %        output(format.bvolume)
  1217. %        new.block
  1218. %        output(format.number.series)
  1219. %        new.sentence
  1220. %        output.check(publisher,"publisher")
  1221. %        output(address)
  1222. %       else
  1223. %        new.block
  1224. %        output.nonnull(format.book.crossref)
  1225. %    fi
  1226. %    output(format.edition)
  1227. %    output.check(format.date,"year")
  1228. %    new.block
  1229. %    output(note)
  1230. %    fin.entry
  1231. %  END
  1232. %
  1233. % The other entry functions are all quite similar, so no "comment version"
  1234. % will be given for them.
  1235. FUNCTION {article}
  1236. { output.bibitem
  1237.   format.authors "author" output.check
  1238.   new.block
  1239.   crossref missing$
  1240.     { journal field.or.null
  1241.       format.vol.num.pages output
  1242.     }
  1243.     { format.article.crossref output.nonnull
  1244.       format.pages output
  1245.     }
  1246.   if$
  1247.   new.block
  1248.   note output
  1249.   fin.entry
  1250. }
  1251. FUNCTION {book}
  1252. { output.bibitem
  1253.   author empty$
  1254.     { format.editors "author and editor" output.check }
  1255.     { format.authors output.nonnull
  1256.       crossref missing$
  1257.     { "author and editor" editor either.or.check }
  1258.     'skip$
  1259.       if$
  1260.     }
  1261.   if$
  1262.   new.block
  1263.   format.btitle "title" output.check
  1264.   crossref missing$
  1265.     { format.bvolume output
  1266.       new.block
  1267.       format.number.series output
  1268.       new.sentence
  1269.       publisher "publisher" output.check
  1270.       address output
  1271.     }
  1272.     { new.block
  1273.       format.book.crossref output.nonnull
  1274.     }
  1275.   if$
  1276.   format.edition output
  1277.   format.date "year" output.check
  1278.   new.block
  1279.   note output
  1280.   fin.entry
  1281. }
  1282. % A booklet is a bound thing without a publisher or sponsoring institution.
  1283. %    Required: title
  1284. %    Optional: author, howpublished, address, month, year, note
  1285. FUNCTION {booklet}
  1286. { output.bibitem
  1287.   format.authors output
  1288.   new.block
  1289.   format.title "title" output.check
  1290.   howpublished address new.block.checkb
  1291.   howpublished output
  1292.   address output
  1293.   format.date output
  1294.   new.block
  1295.   note output
  1296.   fin.entry
  1297. }
  1298. % For the conference entry type, see inproceedings.
  1299. % An inbook is a piece of a book: either a chapter and/or a page range.
  1300. % It may CROSSREF a book.  If there's no volume field, the type field
  1301. % will come before number and series.
  1302. %    Required: author or editor, title, chapter and/or pages, publisher,year
  1303. %    Optional: volume or number, series, type, address, edition, month, note
  1304. FUNCTION {inbook}
  1305. { output.bibitem
  1306.   author empty$
  1307.     { format.editors "author and editor" output.check }
  1308.     { format.authors output.nonnull
  1309.       crossref missing$
  1310.     { "author and editor" editor either.or.check }
  1311.     'skip$
  1312.       if$
  1313.     }
  1314.   if$
  1315.   new.block
  1316.   format.btitle "title" output.check
  1317.   crossref missing$
  1318.     { format.bvolume output
  1319.       format.chapter.pages "chapter and pages" output.check
  1320.       new.block
  1321.       format.number.series output
  1322.       new.sentence
  1323.       publisher "publisher" output.check
  1324.       address output
  1325.     }
  1326.     { format.chapter.pages "chapter and pages" output.check
  1327.       new.block
  1328.       format.book.crossref output.nonnull
  1329.     }
  1330.   if$
  1331.   format.edition output
  1332.   format.date "year" output.check
  1333.   new.block
  1334.   note output
  1335.   fin.entry
  1336. }
  1337. % An incollection is like inbook, but where there is a separate title
  1338. % for the referenced thing (and perhaps an editor for the whole).
  1339. % An incollection may CROSSREF a book.
  1340. %    Required: author, title, booktitle, publisher, year
  1341. %    Optional: editor, volume or number, series, type, chapter, pages,
  1342. %            address, edition, month, note
  1343. FUNCTION {incollection}
  1344. { output.bibitem
  1345.   format.authors "author" output.check
  1346.   new.block
  1347.   format.title "title" output.check
  1348.   new.block
  1349.   crossref missing$
  1350.     { format.in.ed.booktitle "booktitle" output.check
  1351.       format.bvolume output
  1352.       format.number.series output
  1353.       format.chapter.pages output
  1354.       new.sentence
  1355.       publisher "publisher" output.check
  1356.       address output
  1357.       format.edition output
  1358.       format.date "year" output.check
  1359.     }
  1360.     { format.incoll.inproc.crossref output.nonnull
  1361.       format.chapter.pages output
  1362.     }
  1363.   if$
  1364.   new.block
  1365.   note output
  1366.   fin.entry
  1367. }
  1368. % An inproceedings is an article in a conference proceedings, and it may
  1369. % CROSSREF a proceedings.  If there's no address field, the month (& year)
  1370. % will appear just before note.
  1371. %    Required: author, title, booktitle, year
  1372. %    Optional: editor, volume or number, series, pages, address, month,
  1373. %            organization, publisher, note
  1374. FUNCTION {inproceedings}
  1375. { output.bibitem
  1376.   format.authors "author" output.check
  1377.   new.block
  1378.   format.title "title" output.check
  1379.   new.block
  1380.   crossref missing$
  1381.     { format.in.ed.booktitle "booktitle" output.check
  1382.       format.bvolume output
  1383.       format.number.series output
  1384.       format.pages output
  1385.       address empty$
  1386.     { organization publisher new.sentence.checkb
  1387.       organization output
  1388.       publisher output
  1389.       format.date "year" output.check
  1390.     }
  1391.     { address output.nonnull
  1392.       format.date "year" output.check
  1393.       new.sentence
  1394.       organization output
  1395.       publisher output
  1396.     }
  1397.       if$
  1398.     }
  1399.     { format.incoll.inproc.crossref output.nonnull
  1400.       format.pages output
  1401.     }
  1402.   if$
  1403.   new.block
  1404.   note output
  1405.   fin.entry
  1406. }
  1407. % The conference function is included for Scribe compatibility.
  1408. FUNCTION {conference} { inproceedings }
  1409. % A manual is technical documentation.
  1410. %    Required: title
  1411. %    Optional: author, organization, address, edition, month, year, note
  1412. FUNCTION {manual}
  1413. { output.bibitem
  1414.   author empty$
  1415.     { organization empty$
  1416.     'skip$
  1417.     { organization output.nonnull
  1418.       address output
  1419.     }
  1420.       if$
  1421.     }
  1422.     { format.authors output.nonnull }
  1423.   if$
  1424.   new.block
  1425.   format.btitle "title" output.check
  1426.   author empty$
  1427.     { organization empty$
  1428.     { address new.block.checka
  1429.       address output
  1430.     }
  1431.     'skip$
  1432.       if$
  1433.     }
  1434.     { organization address new.block.checkb
  1435.       organization output
  1436.       address output
  1437.     }
  1438.   if$
  1439.   format.edition output
  1440.   format.date output
  1441.   new.block
  1442.   note output
  1443.   fin.entry
  1444. }
  1445. % A mastersthesis is a Master's thesis.
  1446. %    Required: author, title, school, year
  1447. %    Optional: type, address, month, note
  1448. FUNCTION {mastersthesis}
  1449. { output.bibitem
  1450.   format.authors "author" output.check
  1451.   new.block
  1452.   format.title "title" output.check
  1453.   new.block
  1454.   "Master's thesis" format.thesis.type output.nonnull
  1455.   school "school" output.check
  1456.   address output
  1457.   format.date "year" output.check
  1458.   new.block
  1459.   note output
  1460.   fin.entry
  1461. }
  1462. % A misc is something that doesn't fit elsewhere.
  1463. %    Required: at least one of the `optional' fields
  1464. %    Optional: author, title, howpublished, month, year, note
  1465. FUNCTION {misc}
  1466. { output.bibitem
  1467.   format.authors output
  1468.   title howpublished new.block.checkb
  1469.   format.title output
  1470.   howpublished new.block.checka
  1471.   howpublished output
  1472.   format.date output
  1473.   new.block
  1474.   note output
  1475.   fin.entry
  1476.   empty.misc.check
  1477. }
  1478. % A phdthesis is like a mastersthesis.
  1479. %    Required: author, title, school, year
  1480. %    Optional: type, address, month, note
  1481. FUNCTION {phdthesis}
  1482. { output.bibitem
  1483.   format.authors "author" output.check
  1484.   new.block
  1485.   format.btitle "title" output.check
  1486.   new.block
  1487.   "PhD thesis" format.thesis.type output.nonnull
  1488.   school "school" output.check
  1489.   address output
  1490.   format.date "year" output.check
  1491.   new.block
  1492.   note output
  1493.   fin.entry
  1494. }
  1495. % A proceedings is a conference proceedings.
  1496. % If there is an organization but no editor field, the organization will
  1497. % appear as the first optional field (we try to make the first block nonempty);
  1498. % if there's no address field, the month (& year) will appear just before note.
  1499. %    Required: title, year
  1500. %    Optional: editor, volume or number, series, address, month,
  1501. %            organization, publisher, note
  1502. FUNCTION {proceedings}
  1503. { output.bibitem
  1504.   editor empty$
  1505.     { organization output }
  1506.     { format.editors output.nonnull }
  1507.   if$
  1508.   new.block
  1509.   format.btitle "title" output.check
  1510.   format.bvolume output
  1511.   format.number.series output
  1512.   address empty$
  1513.     { editor empty$
  1514.     { publisher new.sentence.checka }
  1515.     { organization publisher new.sentence.checkb
  1516.       organization output
  1517.     }
  1518.       if$
  1519.       publisher output
  1520.       format.date "year" output.check
  1521.     }
  1522.     { address output.nonnull
  1523.       format.date "year" output.check
  1524.       new.sentence
  1525.       editor empty$
  1526.     'skip$
  1527.     { organization output }
  1528.       if$
  1529.       publisher output
  1530.     }
  1531.   if$
  1532.   new.block
  1533.   note output
  1534.   fin.entry
  1535. }
  1536. % A techreport is a technical report.
  1537. %    Required: author, title, institution, year
  1538. %    Optional: type, number, address, month, note
  1539. FUNCTION {techreport}
  1540. { output.bibitem
  1541.   format.authors "author" output.check
  1542.   new.block
  1543.   format.title "title" output.check
  1544.   new.block
  1545.   format.tr.number output.nonnull
  1546.   institution "institution" output.check
  1547.   address output
  1548.   format.date "year" output.check
  1549.   new.block
  1550.   note output
  1551.   fin.entry
  1552. }
  1553. % An unpublished is something that hasn't been published.
  1554. %    Required: author, title, note
  1555. %    Optional: month, year
  1556. FUNCTION {unpublished}
  1557. { output.bibitem
  1558.   format.authors "author" output.check
  1559.   new.block
  1560.   format.title "title" output.check
  1561.   new.block
  1562.   note "note" output.check
  1563.   format.date output
  1564.   fin.entry
  1565. }
  1566. % We use entry type `misc' for an unknown type; BibTeX gives a warning.
  1567. FUNCTION {default.type} { misc }
  1568. % Here are macros for common things that may vary from style to style.
  1569. % Users are encouraged to use these macros.
  1570. %
  1571. % Months are either written out in full or abbreviated
  1572. MACRO {jan} {"Jan."}
  1573. MACRO {feb} {"Feb."}
  1574. MACRO {mar} {"Mar."}
  1575. MACRO {apr} {"Apr."}
  1576. MACRO {may} {"May"}
  1577. MACRO {jun} {"June"}
  1578. MACRO {jul} {"July"}
  1579. MACRO {aug} {"Aug."}
  1580. MACRO {sep} {"Sept."}
  1581. MACRO {oct} {"Oct."}
  1582. MACRO {nov} {"Nov."}
  1583. MACRO {dec} {"Dec."}
  1584. % Journals are either written out in full or abbreviated;
  1585. % the abbreviations are like those found in ACM publications.
  1586. %
  1587. % To get a completely different set of abbreviations, it may be best to make
  1588. % a separate .bib file with nothing but those abbreviations; users could then
  1589. % include that file name as the first argument to the \bibliography command
  1590. MACRO {acmcs} {"ACM Comput. Surv."}
  1591. MACRO {acta} {"Acta Inf."}
  1592. MACRO {cacm} {"Commun. ACM"}
  1593. MACRO {ibmjrd} {"IBM J. Res. Dev."}
  1594. MACRO {ibmsj} {"IBM Syst.~J."}
  1595. MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  1596. MACRO {ieeetc} {"IEEE Trans. Comput."}
  1597. MACRO {ieeetcad}
  1598.  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  1599. MACRO {ipl} {"Inf. Process. Lett."}
  1600. MACRO {jacm} {"J.~ACM"}
  1601. MACRO {jcss} {"J.~Comput. Syst. Sci."}
  1602. MACRO {scp} {"Sci. Comput. Programming"}
  1603. MACRO {sicomp} {"SIAM J. Comput."}
  1604. MACRO {tocs} {"ACM Trans. Comput. Syst."}
  1605. MACRO {tods} {"ACM Trans. Database Syst."}
  1606. MACRO {tog} {"ACM Trans. Gr."}
  1607. MACRO {toms} {"ACM Trans. Math. Softw."}
  1608. MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  1609. MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  1610. MACRO {tcs} {"Theoretical Comput. Sci."}
  1611. %% /usr/local/lib/tex/bibtex/phyjfull.btx, Tue Jun 30 08:37:48 1992
  1612. %% Edit by Nelson H. F. Beebe <beebe@alfred.math.utah.edu>
  1613. %% Change file names in leading comment
  1614. % Journal Title Abbreviations from the Physical Review Style and Notation
  1615. %    Guide, July, 1983, in BAPS Vol. 28.
  1616. %  Selected by Cris Barnes and Charles Karney, March 1988
  1617. % IMPORTANT!! Don't make changes to this file without making the
  1618. %           corresponding changes to
  1619. %            phyjabb.bib
  1620. %            phyjabb.btx
  1621. MACRO {advp} {"Advances in Physics"}
  1622. MACRO {ajp} {"American Journal of Physics"}
  1623. MACRO {ao} {"Applied Optics"}
  1624. MACRO {apl} {"Applied Physics Letters"}
  1625. MACRO {apj} {"Astrophysical Journal"}
  1626. MACRO {baps} {"Bulletin of the American Physical Society"}
  1627. MACRO {cpc} {"Computer Physics Communications"}
  1628. MACRO {cppcf} {"Comments on Plasma Physics and Controlled Fusion"}
  1629. MACRO {fed} {"Fusion Engineering and Design"}
  1630. MACRO {ft} {"Fusion Technology"}
  1631. MACRO {ieeens} {"IEEE Transactions on Nuclear Science"}
  1632. MACRO {ieeeps} {"IEEE Transactions on Plasma Science"}
  1633. MACRO {ijimw} {"International Journal of Infrared and Millimeter Waves"}
  1634. MACRO {ip} {"Infrared Physics"}
  1635. MACRO {jap} {"Journal of Applied Physics"}
  1636. MACRO {jcp} {"Journal of Computational Physics"}
  1637. MACRO {jetp} {"Soviet Physics-JETP"}
  1638. MACRO {jfe} {"Journal of Fusion Energy"}
  1639. MACRO {jfm} {"Journal of Fluid Mechanics"}
  1640. MACRO {jgr} {"Journal of Geophysical Research"}
  1641. MACRO {jmp} {"Journal of Mathematical Physics"}
  1642. MACRO {jne} {"Journal of Nuclear Energy"}
  1643. MACRO {jnec} {"Journal of Nuclear Energy, Part C: Plasma Physics, Accelerators, Thermonuclear Research"}
  1644. MACRO {jnm} {"Journal of Nuclear Materials"}
  1645. MACRO {josa} {"Journal of the Optical Society of America"}
  1646. MACRO {jpp} {"Journal of Plasma Physics"}
  1647. MACRO {jpsj} {"Journal of the Physical Society of Japan"}
  1648. MACRO {jvst} {"Journal of Vacuum Science and Technology"}
  1649. MACRO {nedf} {"Nuclear Engineering and Design/Fusion"}
  1650. MACRO {nf} {"Nuclear Fusion"}
  1651. MACRO {nim} {"Nuclear Instruments and Methods"}
  1652. MACRO {nimpr} {"Nuclear Instruments and Methods in Physics Research"}
  1653. MACRO {nt/f} {"Nuclear Technology/Fusion"}
  1654. MACRO {pf} {"Physics of Fluids"}
  1655. MACRO {pfa} {"Physics of Fluids A: Fluid Dynamics"}
  1656. MACRO {pfb} {"Physics of Fluids B: Plasma Physics"}
  1657. MACRO {pl} {"Physics Letters"}
  1658. MACRO {pla} {"Physics Letters A"}
  1659. MACRO {pnas} {"Proceedings of the National Academy of Sciences of the USA"}
  1660. MACRO {pp} {"Plasma Physics"}
  1661. MACRO {ppcf} {"Plasma Physics and Controlled Fusion"}
  1662. MACRO {prl} {"Physical Review Letters"}
  1663. MACRO {pr} {"Physical Review"}
  1664. MACRO {pra} {"Physical Review A: General Physics"}
  1665. MACRO {ps} {"Physica Scripta"}
  1666. MACRO {rmp} {"Reviews of Modern Physics"}
  1667. MACRO {rsi} {"Review of Scientific Instruments"}
  1668. MACRO {sjpp} {"Soviet Journal of Plasma Phys."}
  1669. MACRO {spd} {"Soviet Physics-Doklady"}
  1670. MACRO {sptp} {"Soviet Physics-Technical Physics"}
  1671. MACRO {spu} {"Soviet Physics-Uspeki"}
  1672. % Now we read in the .BIB entries.
  1673. READ
  1674. % The sortify function converts to lower case after purify$ing; it's
  1675. % used in sorting and in computing alphabetic labels after sorting
  1676. %
  1677. % The chop.word(w,len,s) function returns either s or, if the first len
  1678. % letters of s equals w (this comparison is done in the third line of the
  1679. % function's definition), it returns that part of s after w.
  1680. % This long comment applies only to alphabetic labels
  1681. %
  1682. % The format.lab.names function makes a short label by using the initials of
  1683. % the von and Last parts of the names (but if there are more than four names,
  1684. % (i.e., people) it truncates after three and adds a superscripted "+";
  1685. % it also adds such a "+" if the last of multiple authors is "others").
  1686. % If there is only one name, and its von and Last parts combined have just
  1687. % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
  1688. % we take the first three letters of the last name.  The boolean
  1689. % et.al.char.used tells whether we've used a superscripted "+", so that we
  1690. % know whether to include a LaTeX macro for it.
  1691. %
  1692. % format.lab.names(s) ==
  1693. %  BEGIN
  1694. %    numnames := num.names$(s)
  1695. %    if numnames > 1 then
  1696. %        if numnames > 4 then
  1697. %        namesleft := 3
  1698. %        else
  1699. %        namesleft := numnames
  1700. %        nameptr := 1
  1701. %        nameresult := ""
  1702. %        while namesleft > 0
  1703. %          do
  1704. %        if (name_ptr = numnames) and
  1705. %             format.name$(s, nameptr, "{ff }{vv }{ll}{ jj}") = "others"
  1706. %           then nameresult := nameresult * "{\etalchar{+}}"
  1707. %            et.al.char.used := true
  1708. %           else nameresult := nameresult *
  1709. %                format.name$(s, nameptr, "{v{}}{l{}}")
  1710. %        nameptr := nameptr + 1
  1711. %        namesleft := namesleft - 1
  1712. %          od
  1713. %        if numnames > 4 then
  1714. %        nameresult := nameresult * "{\etalchar{+}}"
  1715. %        et.al.char.used := true
  1716. %    else
  1717. %        t := format.name$(s, 1, "{v{}}{l{}}")
  1718. %        if text.length$(t) < 2 then    % there's just one name-token
  1719. %        nameresult := text.prefix$(format.name$(s,1,"{ll}"),3)
  1720. %        else
  1721. %        nameresult := t
  1722. %        fi
  1723. %    fi
  1724. %    return nameresult
  1725. %  END
  1726. %
  1727. % Exactly what fields we look at in constructing the primary part of the label
  1728. % depends on the entry type; this selectivity (as opposed to, say, always
  1729. % looking at author, then editor, then key) helps ensure that "ignored" fields,
  1730. % as described in the LaTeX book, really are ignored.  Note that MISC is part
  1731. % of the deepest `else' clause in the nested part of calc.label; thus, any
  1732. % unrecognized entry type in the database is handled correctly.
  1733. %
  1734. % There is one auxiliary function for each of the four different sequences of
  1735. % fields we use.  The first of these functions looks at the author field, and
  1736. % then, if necessary, the key field.  The other three functions, which might
  1737. % look at two fields and the key field, are similar, except that the key field
  1738. % takes precedence over the organization field (for labels---not for sorting).
  1739. %
  1740. % The calc.label function calculates the preliminary label of an entry, which
  1741. % is formed by taking three letters of information from the author or editor or
  1742. % key or organization field (depending on the entry type and on what's empty,
  1743. % but ignoring a leading "The " in the organization), and appending the last
  1744. % two characters (digits) of the year. It is an error if the appropriate fields
  1745. % among author, editor, organization, and key are missing, and we use
  1746. % the first three letters of the cite$ in desperation when this happens.
  1747. % The resulting label has the year part, but not the name part, purify$ed
  1748. % (purify$ing the year allows some sorting shenanigans by the user).
  1749. %
  1750. % This function also calculates the version of the label to be used in sorting.
  1751. %
  1752. % The final label may need a trailing 'a', 'b', etc., to distinguish it from
  1753. % otherwise identical labels, but we can't calculated those "extra.label"s
  1754. % until after sorting.
  1755. %
  1756. % calc.label ==
  1757. %  BEGIN
  1758. %    if type$ = "book" or "inbook" then
  1759. %        author.editor.key.label
  1760. %    else if type$ = "proceedings" then
  1761. %        editor.key.organization.label
  1762. %    else if type$ = "manual" then
  1763. %        author.key.organization.label
  1764. %    else
  1765. %        author.key.label
  1766. %    fi fi fi
  1767. %    label := label * substring$(purify$(field.or.null(year)), -1, 2)
  1768. %        % assuming we will also sort, we calculate a sort.label
  1769. %    sort.label := sortify(label), but use the last four, not two, digits
  1770. %  END
  1771. % When sorting, we compute the sortkey by executing "presort" on each entry.
  1772. % The presort key contains a number of "sortify"ed strings, concatenated
  1773. % with multiple blanks between them.  This makes things like "brinch  per"
  1774. % come before "brinch hansen  per".
  1775. %
  1776. % The fields used here are: the sort.label for alphabetic labels (as set by
  1777. % calc.label), followed by the author names (or editor names or organization
  1778. % (with a leading "The " removed) or key field, depending on entry type and on
  1779. % what's empty), followed by year, followed by the first bit of the title
  1780. % (chopping off a leading "The ", "A ", or "An ").
  1781. % Names are formatted: Von Last First Junior.
  1782. % The names within a part will be separated by a single blank
  1783. % (such as "brinch hansen"), two will separate the name parts themselves
  1784. % (except the von and last), three will separate the names,
  1785. % four will separate the names from year (and from label, if alphabetic),
  1786. % and four will separate year from title.
  1787. %
  1788. % The sort.format.names function takes an argument that should be in
  1789. % BibTeX name format, and returns a string containing "   "-separated
  1790. % names in the format described above.  The function is almost the same
  1791. % as format.names.
  1792. % This long comment applies only to alphabetic labels, when sorted
  1793. %
  1794. % Now comes the final computation for alphabetic labels, putting in the 'a's
  1795. % and 'b's and so forth if required.  This involves two passes: a forward
  1796. % pass to put in the 'b's, 'c's and so on, and a backwards pass
  1797. % to put in the 'a's (we don't want to put in 'a's unless we know there
  1798. % are 'b's).
  1799. % We have to keep track of the longest (in width$ terms) label, for use
  1800. % by the "thebibliography" environment.
  1801. %
  1802. % VAR: longest.label, last.sort.label, next.extra: string
  1803. %      longest.label.width, last.extra.num: integer
  1804. %
  1805. % initialize.longest.label ==
  1806. %  BEGIN
  1807. %    longest.label := ""
  1808. %    last.sort.label := int.to.chr$(0)
  1809. %    next.extra := ""
  1810. %    longest.label.width := 0
  1811. %    last.extra.num := 0
  1812. %  END
  1813. %
  1814. % forward.pass ==
  1815. %  BEGIN
  1816. %    if last.sort.label = sort.label then
  1817. %        last.extra.num := last.extra.num + 1
  1818. %        extra.label := int.to.chr$(last.extra.num)
  1819. %    else
  1820. %        last.extra.num := chr.to.int$("a")
  1821. %        extra.label := ""
  1822. %        last.sort.label := sort.label
  1823. %    fi
  1824. %  END
  1825. %
  1826. % reverse.pass ==
  1827. %  BEGIN
  1828. %    if next.extra = "b" then
  1829. %        extra.label := "a"
  1830. %    fi
  1831. %    label := label * extra.label
  1832. %    if width$(label) > longest.label.width then
  1833. %        longest.label := label
  1834. %        longest.label.width := width$(label)
  1835. %    fi
  1836. %    next.extra := extra.label
  1837. %  END
  1838. % Now comes the computation for numeric labels.
  1839. % We use either the sorted order or original order.
  1840. % We still have to keep track of the longest (in width$ terms) label, for use
  1841. % by the "thebibliography" environment.
  1842. STRINGS { longest.label }
  1843. INTEGERS { number.label longest.label.width }
  1844. FUNCTION {initialize.longest.label}
  1845. { "" 'longest.label :=
  1846.   #1 'number.label :=
  1847.   #0 'longest.label.width :=
  1848. }
  1849. FUNCTION {longest.label.pass}
  1850. { number.label int.to.str$ 'label :=
  1851.   number.label #1 + 'number.label :=
  1852.   label width$ longest.label.width >
  1853.     { label 'longest.label :=
  1854.       label width$ 'longest.label.width :=
  1855.     }
  1856.     'skip$
  1857.   if$
  1858. }
  1859. EXECUTE {initialize.longest.label}
  1860. ITERATE {longest.label.pass}
  1861. % Now we're ready to start writing the .BBL file.
  1862. % We begin, if necessary, with a LaTeX macro for unnamed names in an alphabetic
  1863. % label; next comes stuff from the `preamble' command in the database files.
  1864. % Then we give an incantation containing the command
  1865. %     \begin{thebibliography}{...}
  1866. % where the `...' is the longest label.
  1867. %
  1868. % We also call init.state.consts, for use by the output routines.
  1869. FUNCTION {begin.bib}
  1870. { preamble$ empty$
  1871.     'skip$
  1872.     { preamble$ write$ newline$ }
  1873.   if$
  1874.   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  1875. }
  1876. EXECUTE {begin.bib}
  1877. EXECUTE {init.state.consts}
  1878. % Now we produce the output for all the entries
  1879. ITERATE {call.type$}
  1880. % Finally, we finish up by writing the `\end{thebibliography}' command.
  1881. FUNCTION {end.bib}
  1882. { newline$
  1883.   "\end{thebibliography}" write$ newline$
  1884. }
  1885. EXECUTE {end.bib}
  1886.